/*
 * @Author: baoshijie baoshijie
 * @Date: 2023-01-30 17:41:35
 * @LastEditors: baoshijie
 * @LastEditTime: 2024-10-15
 * @FilePath: \notomWeb\src\permission.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import router from "./router";
import store from "./store";
import { ElMessage } from "element-plus";

import { doLoginByTicket } from "@/api/login";
import { goSsoAuth } from "@/utils/permission.js";

// const whiteList = ["/login", "/bind", "/register"];

router.beforeEach((to, from, next) => {

  document.title = to.meta.title || '默认标题';

  
  if (store.getters.permission_routes.length === 0) {
    store.dispatch("GenerateRoutes").then((accessRoutes) => {
      accessRoutes.forEach((route) => {
        router.addRoute(route); // 动态添加可访问路由表
      });
      next({ ...to, replace: true });
    });
  } else {
    next();
  }
});
